import { defineStore } from 'pinia'
import router from '../../router'
const tagsStore = defineStore('tags', {
  state: () => ({
    tagList: [{
      name: '首页',
      url:'main'
    }],
    currentMenu: null
  }),
  actions: {
    selectMenu(tag) {
      if (tag.name !== 'main') {
        this.currentMenu = tag
        let result = this.tagList.findIndex((item) => item.name == tag.name)
        result == -1 ? this.tagList.push(tag) : ''
      } else {
        this.currentMenu = null
      }
    },
    closeTags(tag) {
      let delItem = this.tagList.findIndex((item) => item.name == tag.name)
      this.tagList.splice(delItem, 1)
    }
  }
})
export default tagsStore
